package com.atguigu.gmall.weball.retry;

import feign.RetryableException;
import feign.Retryer;

/**
 * @author lfy
 * @Description  自定义重试器
 * @create 2023-08-28 16:53
 */
public class MyRetryer implements Retryer {

    private int count = 0;

    @Override
    public void continueOrPropagate(RetryableException e) {
        //continue 不抛异常就是继续重试，抛异常重试结束
        count++;
        if (count > 5) {
            throw  e; //中断重试
        }
    }

    @Override
    public Retryer clone() {
        return new MyRetryer();
    }
}
